package com.zyl.pts.web.controller;

import com.zyl.pts.config.enums.CodeAndMessageEnum;
import com.zyl.pts.config.result.Result;
import com.zyl.pts.service.SourceService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

/**
 * @version v1.0
 * @ProjectName: product_source
 * @Package: com.zyl.pts.web.controller
 * @ClassName: SourceController
 * @Description TODO(溯源信息)
 * @Author 翟玉龙
 * @Date 2024/11/25-9:34
 */
@Tag(name = "溯源信息", description = "溯源信息")
@RestController
@RequestMapping("/source")
public class SourceController {

    private final SourceService sourceService;

    public SourceController(SourceService sourceService) {
        this.sourceService = sourceService;
    }

    /**
     * 获取溯源信息
     * @param animalId 动物id
     * @return {@link Result }<{@link ? }>
     */
    @Operation(summary = "获取溯源信息")
    @GetMapping("/{animalId}")
    public Result<?> getSource(
            @PathVariable("animalId") String animalId
    ) {
        return Result.success(
                CodeAndMessageEnum.SUCCESS,
                sourceService.getSourceInfo(animalId)
        );
    }

}
